import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/",
      component: () => import("@/pages/Index.vue"),
      redirect: "/demo",
      children: [
        {
          path: "/demo",
          component: () => import("@/pages/Demo/index.vue"),
        },
        {
          path: "/home",
          component: () => import("@/pages/Home/index.vue"),
        },
      ],
    },
  ] as Array<RouteRecordRaw>,
});

// 路由守卫
router.beforeEach((to, from, next) => {
  console.log(to, from);

  if (from.path !== "/") {
    // 路由变化修
    next();
  } else {
    next();
  }
  // 判断登录状态
  // ......
});

export default router;
